<template>
	<view class="" style="height: 100vh; background-color: #FFFFFF;">
		<!-- 头部 -->
		<!-- <view class="">
			<view class="uni-page-head" v-if="titleFlag">
				<image class="common-title-img" style="left: 20rpx;"
					:src="require('../../static/imges/fanhui.png')" @click="back()"></image>
					<view class="common-title-img">
						<u-icon name="arrow-right" color="#FFFFFF" width="20rpx" height="20rpx" size="48" @click="back()"></u-icon>
					</view> 
				<view class="uni-page-head-title">
					服务-赋码贴签
				</view>
			</view>
			<view v-if="titleFlag" style="margin-top: 98rpx;">
				这个盒子是用来撑空间，又不想改变下边的body盒子 所以在这加了一个空盒子，可以根据新老MOA判断 
			</view>
		</view> -->
		<view class="" style="padding: 10rpx;background: #FFFFFF;">
			<view class="contentTitle" style="height: 80rpx;">
				<image style="width: 45rpx;height: 40rpx;margin-bottom: -5px;" src="../../static/imges/wendang3.png" mode=""></image>
				物资信息
			</view>
			<view class="item">
				<text class="itemLeft">标签ID</text>
				<text class="itemRight">{{labelId}}</text>
			</view>
			<view class="item" style="padding-right: 20px;">
				<text class="itemLeft"><text class="xing">*</text>物料种类</text>
				<view @click="confirmerty" style="padding-left: 10rpx;">
					<text v-if="materialCodeert==null" style="color: gray;">请选择物料种类</text>
					<text v-if="materialCodeert!=null"  style="color: black;">{{materialCodeert}}</text>
					<!-- <input class="itemRight"   placeholder="请选择物料种类" v-model="materialCodeert" /> -->
				</view>
				
				<!-- <text>21A05SDLY0901057</text> -->
				<!-- <uni-combox :candidates="candidates" :placeholder="placeholder1 || '请选择物料种类'" @input="checkboxChange" v-model="city" ></uni-combox> -->
				<!-- <u-input v-model="placeholder1" type="select" :border="false" @click="showWuLiao = true" placeholder="请选择物料种类" />
				<u-select title="" v-model="showWuLiao" mode="mutil-column-auto" z-index="666" :list="materialTypeList" @confirm="confirm1" style="position: relative;"></u-select> -->
				<!-- <text class="itemRight">{{placeholder1}}</text> -->
			</view>
			<view class="item">
				<text class="itemLeft"><text class="xing">*</text>物料分级分类</text>
				<!-- <text style="width: 70%;" @click="show = true">21A05SDLY0901057</text> disabled -->
				<view @click="classifyClick" style="padding-left: 10rpx;">
					<text v-if="!classify" style="color: gray;">请选择物料分级分类</text>
					<text v-if="classify"  style="color: black;">{{classify}}</text>
					<!-- <input class="itemRight" type="text" placeholder="请选择物料分级分类" readonly="true" v-model="classify" disabled /> -->
				</view>
				<u-select :mask-close-able="false" title="" value-name="cateTypeCode" label-name="cateTypeName" v-model="show"   mode="mutil-column-auto" z-index="666" :list="list" @confirm="confirm" style="position: relative;"></u-select>
				<!-- <u-select v-model="show" mode="mutil-column-auto" :list="listered" @confirm="confirm" value-name="cateTypeCode" label-name="cateTypeName"   ></u-select> -->
				<!-- 分级分类卡片三级展示 -->
				<view class="cardStyle" v-show="show" style="">
					<view class="" style="width: 60%;height: 100%;">
						<!-- <view class="" v-for="(item,index) in materialCard" :key="item" style=""> -->
						<view class="">
							<text>{{materialCard.oneLevel}}</text>
						</view>
						<view class="">
							<text>{{materialCard.twoLevel}}</text>
						</view>
						<view class="">
							<text>{{materialCard.threeLevel}}</text>
						</view>
						<view class="">
							<text>{{materialCard.fourLevel==null?"":materialCard.fourLevel}}</text>
						</view>
					</view>
				</view>
				<!-- 四级五级提示文字 -->
				<view v-show="showSW" style="position: fixed;bottom: 400rpx;left: 0;text-align: center;width: 100%;z-index: 999;
					font-size: 30rpx;font-weight: bold;display: flex;justify-content: space-around;background: #FFFFFF;
					height: 100rpx;align-items: flex-end;
				">
					
					<text style="position: relative;left: 20rpx;" v-if="placeholder1==4">四级（小类）</text>
					<text style="position: relative;left: 20rpx;">五级（细类）</text>
					
				</view>
			</view>
			<view class="item">
				<text class="itemLeft"><text class="xing">*</text>物料名称</text>
				<!-- <text @click="show1 = true">21A05SDLY0901057</text> -->
				<view @click="open" style="padding-left: 10rpx;">
					<text v-if="!materialName" style="color: gray;">请选择物料名称</text>
					<text v-if="materialName"  style="color: black;">{{materialName}}</text>
				</view>
				<!-- <u-select height="auto" v-model="show1" value-name="catCode" label-name="catName" mode="mutil-column-auto" :list="materialNameTypeList" @confirm="confirm"></u-select> -->
				<!-- <text @click="show1 = true" style="display: inline-block;width: 70%;">{{materialName}}</text> -->
			</view>
			<view class="item">
				<text class="itemLeft"><text class="xing">*</text>物料编码</text>
				<view @click="open" style="padding-left: 10rpx;">
					<text v-if="!materialCode" style="color: gray;">请选择物料编码</text>
					<text v-if="materialCode"  style="color: black;">{{materialCode}}</text>
					<!-- <input class="itemRight" disabled type="text" placeholder="请选择物料编码" v-model="materialCode" /> -->
				</view>
			</view>
       <!--服务-赋码贴签展示绑定数量-->
        <view class="item" v-if="isElectrical">
            <text class="itemLeft"><text class="xing">*</text>数量(米)</text>
            <view style="padding-left: 10rpx;">
                <input type="digit" v-model="detailNum" placeholder="请输入" style="font-size: 28rpx"/>
            </view>
        </view>
		</view>
		<view  v-if="Sinformation" class="" style="padding: 10rpx;background: #FFFFFF;">
			<view class="contentTitle" style="height: 80rpx;">
				<image style="width: 45rpx;height: 40rpx;margin-bottom: -5px;" src="../../static/imges/wendang3.png" mode=""></image>
				贴签信息
			</view>
			<view class="item">
				<text class="itemLeft"><text class="xing">*</text>贴签位置</text>
				<text class="itemRight"><input type="text"  v-model="Sticker"   placeholder="请输入贴签位置" style="font-size: 28rpx;" maxlength="80"/></text>
			</view>
			<view class="item" style="display: block;">
				<text class="itemLeft" style="padding-top: 10rpx;"><text class="xing">*</text>贴签照片</text>
				<view>
					<scroll-view scroll-x="true" style="white-space: nowrap;width: 100%;" scroll-left="120"
						show-scrollbar="true">
						<view class="photo-item"  v-for="(image,index2) in tupianLister" :key="index2">
							<image class="photo-image"  :src="fileData(image.fileUrl)" :data-src="image"
								@tap="previewImage(image,index2)" style="width: 120rpx;height: 120rpx"></image>
							<image @click="delectImg(index2)" class="photo-delete-btn"
								src="../../static/imges/shanchu2.png">
							</image>
						</view>
						<view class="photo-item"  v-if="showPhotoer">
								<image class="photo-image"  :src="require('@/static/imges/shangchuanimg.png')"
								       style="width: 122rpx;height: 122rpx;"
								@click="showPhoto()"></image>
						</view>
					</scroll-view>
				</view>
			</view>
		</view>
		<!-- <picker @change="bindPickerChange" :value="index" :range="array">
			<view class="uni-input">{{array[index]}}</view>
		</picker> -->
		<!-- <button @click="open">打开弹窗</button> -->
		<uni-popup ref="popup" style="height: 100px;">
			<view style="background-color:#fff ;">
				<span class="off" @click="close" >X</span>
				<view class="h1">
					 <span>物料名称</span>
				</view>
			  <view class="top">
				  <input  class="t-c1" type="text" placeholder="请输入物料名称查询" v-model="searchName" >
				  <input  class="t-c2" type="text" placeholder="请输入物料编码查询" v-model="searchCode" >
			  </view>
			  <view style="text-align: center;margin-top: 10px;">
				  <span style="font-weight: bold;">请选择</span>
				   <u-line :hair-line="false" color="black" />
			  </view>
			 
			</view>
			<scroll-view style="height: 250px;background-color: #fff;border: 1px solid #E4E4E4;border-width: 5px 0;" class="" :scroll-y="true">
			    <view style="margin: 5px 0;padding-left: 5px;background: #F2F2F2;" class="" v-for="(item,index) in materialNameTypeList"
				 v-show="itemShow(item)"
				 :key="item.catCode" @click="materialName=item.catName;materialCode=item.catCode;close()">
			    	<view class="">
			    		{{item.catName}}
			    	</view>
			    	<view style="color:#F0AD4E">
			    		物料编码：{{item.catCode}}
			    	</view>
			    </view>
			</scroll-view>
		</uni-popup>
		<!-- 红色提示文字 -->
		<view class="" v-show="redTipShow" style="text-align: center;color: #D9001B;margin-top: 20px;font-size: 18px;font-weight: bold;">
			{{'请先选择【'+this.redTip+'】'}}
		</view>
		<!-- <button type="default" @click="ceshiFuction()">点击选择物料</button> -->
		<view class="buttonBox">
			<button v-debounce="() => onOk(1)" type="warn" style="font-size: 28rpx;width: 48%;">确认</button>
			<button v-debounce="() => onOk(2)" type="warn" style="font-size: 28rpx;width: 48%;">取消</button>
		</view>
		 <ElectricCableert ref="electricCable" @mylick="mylick"></ElectricCableert>
		 
		<view class="">
			<u-popup v-model="bottomShow" mode="bottom">
				<view style="height: 300rpx;">
					<view v-debounce="() => getCamera()"
						style="width: 100%;height: 100rpx;border-bottom: 1px solid #D3D3D3;text-align: center;line-height: 100rpx;">
						<text style="font-size: 30rpx;">拍摄</text>
		
					</view>
					<view v-debounce="() => getSelectImg()"
						style="width: 100%;height: 100rpx;border-bottom: 1px solid #D3D3D3;text-align: center;line-height: 100rpx;">
						<text style="font-size: 15px;">相册选择</text>
		
					</view>
					<view @click="cancel()"
						style="width: 100%;height: 100rpx;border-bottom: 1px solid #D3D3D3;text-align: center;line-height: 100rpx;">
						<text style="font-size: 15px;">取消</text>
		
					</view>
				</view>
			</u-popup>
		</view>
	</view>
	
</template>

<script>
	import ElectricCableert from "./components/ElectricCableert.vue";
	import { getGPS, exceedDistance } from "../utils/gpsUtil";
	import { checkClickAbled } from "./utils";
	export default{
		components: {
		  ElectricCableert
		},
		data(){
			return {
          detailNum:'',
				ionerid:"",
				Permissionid:"",
				Sticker:"",
				fileer:"",
				showPhotoer:true,				
				bottomShow:false,
				tupianLister:[],
				Sinformation:false,
				Sinformationer:false,
				
				
				
				
				base64er:"",
				currenName:"",
				prjId:'',
				serviceCode:'',
				labelId:'',
				titleFlag:true,
				showere:false,
				listered:  [
					
				],
				
				
				materialCodeert:null,
				redTip:'', //红色提示文字
				redTipShow:false,
				candidates:[
					'变压器','简易塔','楼面抱杆','砖混房屋','10KV电力电缆','1KV以下电力电缆'
				],
				city: '',
				placeholder1:'',
				show:false,
				show1:false,
				showSW:false, // 四级五级分类文字显示
				showWuLiao:false, // 物料种类选择框
				classify:'', //分级分类
				materialName:'', //物料名称
				materialCode:'', //物料编码
				materialType:'', //物料种类
				materialNameTypeList:[], //筛选后物料编码，种类的数组
				materialCloneLists: [], //复制请求的数据
				materialTypeList: [],
				// materialTypeList:[
				// 	{label:'变压器',value:'01240501'},
				// 	{label:'简易塔',value:'010103'},
				// 	{label:'楼面抱杆',value:'010202'},
				// 	{label:'砖混房屋',value:'01210101'},
				// 	{label:'10KV电力电缆',value:'01610101'},
				// 	{label:'1KV以下电力电缆',value:'01610102'}
				// ],
				// array: ['中国', '美国', '巴西', '日本'],
				// index: 0,
				list:[],
				materialCard:[],
				materialCardList:[ //分级分类弹框卡片三级展示
					{
						label:'变压器',
						value:[
							'一级（板块）：工程物资',
							'二级（大类）：电力引入设备',
							'三级（中类）：变压/稳压设备',
							'四级（小类）：变压器'
						]
					},
					{
						label:'简易塔',
						value:[
							'一级（板块）：工程物资',
							'二级（大类）：地面塔',
							'三级（中类）：简易塔'
						]
					},
					{
						label:'楼面抱杆',
						value:[
							'一级（板块）：工程物资',
							'二级（大类）：楼面塔',
							'三级（中类）：楼面抱杆'
						]
					},
					{
						label:'砖混房屋',
						value:[
							'一级（板块）：工程物资',
							'二级（大类）：基站机房',
							'三级（中类）：基站机房',
							'四级（小类）：砖混房屋'
						]
					},
					{
						label:'10KV电力电缆',
						value:[
							'一级（板块）：工程物资',
							'二级（大类）：通用工程物资',
							'三级（中类）：电力电缆',
							'四级（小类）：10KV电力电缆'
						]
					},
					{
						label:'1KV以下电力电缆',
						value:[
							'一级（板块）：工程物资',
							'二级（大类）：通用工程物资',
							'三级（中类）：电力电缆',
							'四级（小类）：1KV以下电力电缆'
						]
					},
					{
						label:'水泥杆路',
						value:[
							'一级（板块）：工程物资(基础设施)',
							'二级（大类）：通用工程物资',
							'三级（中类）：杆路',
							'四级（小类）：杆路'      
						],
						},
						{
							label:'油木杆路',
							value:[
								'一级（板块）：工程物资(基础设施)',
								'二级（大类）：通用工程物资',
								'三级（中类）：杆路',
								'四级（小类）：杆路'      
							],
							},
							{
								label:'复合材料杆路',
								value:[
									'一级（板块）：工程物资(基础设施)',
									'二级（大类）：通用工程物资',
									'三级（中类）：杆路',
									'四级（小类）：杆路'      
								],
							},
			
				],
				searchName: '',
				searchCode: ''	,
          isElectrical:false
			}
		},
      //一个总包服务下对非外电电力电缆赋码贴签时若该总包服务下已有某个非外电电力电缆物料编码签码，则选择明细物料编码时需过滤已贴签的非外电电缆物料编码
      //对于电力电缆类（外电电缆和非外电电缆）物资，进行赋码贴签时需填写绑定数量，如下图，服务-赋码贴签页面增加必填字段“*数量(米)”，
      //仅选择物料为电缆类物资时显示该字段，赋码贴签完成后总包类服务页签贴签明细物料同步显示“数量(米)”
      //然后赋码贴签和到货确认页面的绑定数量字段不让他编辑了
		onLoad(option) {
			this.prjId = option.prjId || ''
			this.serviceCode = option.serviceCode || ''
			this.labelId = option.labelId || ''
			this.ionerid=this.prjId;
			
			let panduan1 = option.serviceType == '1'
			
			// 根据服务类型 和 项目类型对物料分类选择框内容进行筛选
			// if( panduan1 ){
			// 	if(panduan2){
			// 		this.materialTypeList = [
			// 			{label:'变压器',value:'01240501'},
			// 			{label:'简易塔',value:'010103'},
			// 			{label:'楼面抱杆',value:'010202'}
			// 		]
			// 	}else if(!panduan2){
			// 		this.materialTypeList = [
			// 			{label:'变压器',value:'01240501'}
			// 		]
			// 	}
				
			// }else if(option.serviceType == '2'){
			// 	this.materialTypeList = [
			// 		{label:'变压器',value:'01240501'}
			// 	]
			// }else if(option.serviceType == '3'){
			// 	this.materialTypeList = [
			// 		{label:'砖混房屋',value:'01210101'}
			// 	]
			// }
			this.getLister();
			this.Permissioner()
		},
		watch:{
			show(newValue){
				if(!newValue){
					this.showSW = false
				}
			}
		},
		methods:{
			previewImage(index,e) {
				// this.type = "center"
				// this.$refs.popup.open( "center")
				let lister=[];
				this.tupianLister.forEach((item)=>{
					lister.push(item.fileUrl)
				})
          let current=this.fileData(e);
          let urls=lister.map((item)=>{
              return this.fileData(item);
          })
          uni.previewImage({
              current,
              urls,
          })
			},
			delectImg(x){
				console.log("删除图片",x)
				this.tupianLister.splice(x, 1)
				this.showPhotoer=true;
			},
      fileData(url){
          return (window.location.protocol + "//" + window.location.host + process.uniEnv.BASE_JM+"/pic/openUrl?httpUrl="+ url)
      },
			fiwfwsfsferer(url){
				console.log("照片")
				uni.uploadFile({
					url: process.uniEnv.BASE_JM+"/pic/uploadFile",
					filePath: url,
					formData:{
						docType:"A1102",
						aiRecognitionType:"0",
						supplierUserAccount:"hudf"
					},
					// formData:data.aiInfo || {},
					name: 'file',
					header: {
						'sysToken': uni.getStorageSync("PMStoken"),
					},
					success: ((res) => {
						let data=JSON.parse(res.data)
						console.log("canshu11",data)
						if(data.code=="200"){
							this.showPhotoer=false;
							this.tupianLister.push({
								fileUrl:data.data.innerHttpUrl,
								imgid:data.data.fileId
							})
						}else{
							uni.showModal({
							  title: "温馨提示",
							  content:data.msg==null?"上传失败,请重新选择":data.msg,
							  showCancel: false,
                confirmColor: '#eb4b4b',
							});
						}
						
					}),
					fail: ((err) => {
						reject(err)
						uni.hideLoading()
					}),
					complete: () => {
						uni.hideLoading()
					}
				});
			},
			Permissioner() {
				uni.request({
					url:uni.getStorageSync("PMS20url")+"/api/app/mainMaterialLable/isVirtualOrRoom?prjId="+this.ionerid,
					method: 'post',
					dataType: 'json',
					timeout: 10000 * 60,
					header: {
					  "sysToken": uni.getStorageSync("PMStoken"),
					},
					data: {},
					success: (res) => {
						uni.hideLoading();
						console.log('获取图片地址:', res.data);
						if(res.data.code=="200"){
							if(res.data.data){
								this.Sinformation=true;
								this.Sinformationer=true;
							}
							console.log('获取图片地址:');
							// this.Sinformation=true;
							// this.Sinformationer=true;
						}
						uni.hideLoading();
						uni.stopPullDownRefresh();	
					},
					fail: (data, code) => {
						uni.hideLoading();
						uni.stopPullDownRefresh();
						console.log('fail' + JSON.stringify(data));
					}
				});
			},
			
			
			// 上传照片
			showPhoto() {
				console.log("获取的值==" );
				this.bottomShow = true;
			},
			//调用MOA拍照
			
			getCamera() {
				this.bottomShow = false
				let that = this
				
				imp.iCamera.open(
				 {
				  quality: 84, //图片质量
				  encodingType: imp.iCamera.EncodingType.JPEG, //图片格式
				 }, 
				 (successData)=> {
				  // console.log('这是拍照所所得：',successData); 
				  var base64Top = 'data:image/jpg;base64,';
				  
				  this.fiwfwsfsferer(base64Top+successData.originalData)
				 },
				 (err)=> {
				  uni.showModal({
    confirmColor: '#eb4b4b',
				  	title: '温馨提示',
				  	content: "相机调用失败",
				  	showCancel: false,
				  });
				 }
				);
			
				
				
			},
			//调用MOA相册
			getSelectImg() {
				this.bottomShow = false
				let that = this
				 console.log('选择图片了：'); 
				var option = {
					quality: 84,
					encodingType: imp.iCamera.EncodingType.JPEG,
					sizeLimit:1024*2,
					num:1,
					// targetWidth: 0,
					// targetHeight: 0,
					// watermark: {
					// 	content: "项目编码：345678",
					// 	color: "red",
					// 	algin: "left",
					// 	valign: "buttom"
					// }
				};
			
				var failed = (info) => {
					uni.showModal({
    confirmColor: '#eb4b4b',
						title: '温馨提示',
						content: "相机调用失败",
						showCancel: false,
					});
				};
				var success = (info) => {
				
				     var base64Top = 'data:image/jpg;base64,'
					setTimeout(() => {
					for (let i = 0; i < info.length; i++) {
						  this.fiwfwsfsferer(base64Top+info[i].thumbnailData)
					}
					}, 300); 
					
				};
				imp.iCamera.select(option, success, failed);
				
			},
			
			
			// 取消拍照
			cancel() {
				this.bottomShow = false
			},
			
			
			
			
			mylick(str){
				 console.log("来自子组件穿的数据：",str);
				 if(this.Sinformationer){
					 if(str.value=="0161010201"||str.value=="0161010101"){
						this.Sinformation=false;
					 }else{
						this.Sinformation=true
					 }
				 }
				this.materialCodeert=str.label
				this.confirm1(str)
			},
			confirm1(value){
				
				console.log("value",value)
				this.materialName = '' //重置物料名称
				this.materialCode = '' //重置物料编码
				this.redTipShow = false //隐藏红色文字
				// console.log(1111111111111111,value)
				this.materialType = value.value
				
				// this.materialCardList.forEach(item=>{
				// 	if(item.label == value.label){
				// 		this.materialCard = item.value
				// 	}
				// })
				this.getWuliaoList()
				this.reset()
			},
			getLister() {
				console.log("准备调接口了")
				
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				uni.request({
					//url: uni.getStorageSync('url') + "/pms/app/complete/queryAppMaterialCatConfigList?prjId=30006589&serverCode=90300103059602083z0248",
					//url: uni.getStorageSync('url') + "/pms/app/complete/queryAppMaterialCatConfigList?prjId="+this.prjId+"&serverCode="+this.serviceCode,
					url: uni.getStorageSync("PMS20url") + "/api/app/serverLable/queryAppMaterialCatConfigList?prjId="+this.prjId+"&serverCode="+this.serviceCode,
					method: 'GET',
					dataType: 'json',
					timeout: 10000 * 60,
					header: {
						"sysToken": uni.getStorageSync("PMStoken"),
						
					},
					data: {
						
					},
					success: (res) => {
						uni.hideLoading();
						//console.log('获取项目列表数据:' + JSON.stringify(res));
						console.log('000获取公告数据:', res.data);
						//console.log('URL:' + uni.getStorageSync('url') + url);
						var data = res.data;
						if (data.code == "200") {
							this.materialTypeList=data.data
							
						}else{
							uni.showModal({
    confirmColor: '#eb4b4b',
								title: '温馨提示',
								content: JSON.stringify(data.message),
								showCancel:false,
							})
						}
			
						uni.hideLoading();
						uni.stopPullDownRefresh();
			
					},
					fail: (data, code) => {
						uni.hideLoading();
						uni.stopPullDownRefresh();
						
					}
				});
			
			},
			itemShow(item){
				let flagName=true
				let flagCode=true
				if(this.searchName!='' && item.catName.indexOf(this.searchName)<0){
					flagName=false
				}
				if(this.searchCode!='' && item.catCode.indexOf(this.searchCode)<0){
					flagName=false
				}
				return (flagName && flagCode)
			},
			open() {
				this.searchName=''
				this.searchCode=''
				if(!this.materialType || !this.classify){
					this.redTip = '物料分级分类'
					this.redTipShow = true
					return
				}
				this.$refs.popup.open('bottom')
			},
			close() {
				this.$refs.popup.close()
			},
			back(){
				uni.navigateBack({
					delta: 1
				});
			},
			// 物料种类选择触发
			
			// 重置清空
			reset(){
				this.classify = ''
				this.materialName = ''
				this.materialCode = ''
			},
			// 点击物料分级分类
			classifyClick(){
				console.log("点击物料分级分类")
				if(!this.materialType){
					this.redTip = '物料种类'
					this.redTipShow = true
					return
				}
				this.show = true
				const that = this
				setTimeout(()=>{
					that.showSW = true
				},300)
			},
			// 选择物料分级分类后触发
			confirm(value){
				this.materialName = '' //重置物料名称
				this.materialCode = '' //重置物料编码
				this.redTipShow = false //隐藏红色文字
				console.log('物料分级分类确定按钮',value)
				// 赋值给物料分级分类表单
				var item
				if(value.length==1){
					item=value[0].value
                    console.log('1111',item)
					 this.classify=value[0].label
				}else{
					item=value[1].value
					  console.log('222',item)
					  this.classify =  value.map((i,index)=>{
					  	return i.label
					  }).join('-')
				}
				
				// 筛选赋值给 物料名称物料编码数组
				this.getListrtyi(item);
				this.getIsElectrical(item);

			},
        getIsElectrical(item){
          this.$axios.get('/material/api/app/serverLable/queryIsNeedNum',{
              fiveCode:item,
              prjId:this.prjId
          }).then((res)=>{
              this.isElectrical=res.data
          })
        },
			getListrtyi(item) {
				console.log("准备调接口了")
				
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				uni.request({
					//url: uni.getStorageSync('url') + "/pms/app/complete/queryAppMaterialCatConfigList?prjId=30006589&serverCode=90300103059602083z0248",
					//url: uni.getStorageSync('url') + "/pms/app/complete/queryAppMaterialCatConfigList?prjId="+this.prjId+"&serverCode="+this.serviceCode,
					url: uni.getStorageSync("PMS20url") + "/api/app/serverLable/querCategoryInfo?fiveCode="+item+"&serviceCode="+this.serviceCode+"&prjId="+this.prjId,
					method: 'GET',
					dataType: 'json',
					timeout: 10000 * 60,
					header: {
						"sysToken": uni.getStorageSync("PMStoken"),
						
					},
					data: {
						
					},
					success: (res) => {
						uni.hideLoading();
						//console.log('获取项目列表数据:' + JSON.stringify(res));
						console.log('物料数据', res.data);
						//console.log('URL:' + uni.getStorageSync('url') + url);
						var data = res.data;
						if (data.code == "200") {
							
							this.materialNameTypeList=data.data
							console.log('获取物料列表数据:' ,this.materialNameTypeList);
						}else{
							uni.showModal({
    confirmColor: '#eb4b4b',
								title: '温馨提示',
								content: JSON.stringify(data.message),
								showCancel:false,
							})
						}
			
						uni.hideLoading();
						uni.stopPullDownRefresh();
			
					},
					fail: (data, code) => {
						uni.hideLoading();
						uni.stopPullDownRefresh();
						
					}
				});
			
			},
			confirmerty(){
				console.log('筛选数据')
				
				 this.$refs.electricCable.opener(
				   this.materialTypeList
				 );
			},
			// 将请求到的数据进行筛选调整
			// dataFilter(materialLists,code){
			// 	if(materialLists[0].child[0].child === null){
			// 		this.list = materialLists.map(item=>{
			// 			return {...item,child}
			// 		})
			// 	}else if(materialLists[0].child === null){
			// 		this.list = materialLists.map((item,index)=>{
			// 			let child = item.child.map((item1,index1)=>{
			// 				return {...item1,child:null}
			// 			})
			// 			return {...item,child}
			// 		})
			// 	}
			// 	console.log('筛选数据',this.list,111111,materialLists)
			// },
			// 请求接口
			getWuliaoList(){
				console.log("出发")
				
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				let that=this
				uni.request({
					url: uni.getStorageSync("PMS20url")  + "/api/app/serverLable/queryCategoryTypeAndDesc?prjId="+ this.prjId +"&serviceCode="+ this.serviceCode +"&categoryType=" + this.materialType,
					// url: uni.getStorageSync('url') + "/pms/app/complete/querCategoryInfo?prjId="+ this.prjId +"&serviceCode="+ this.serviceCode +"&categoryType=" + this.materialType,
					method: 'GET',
					dataType: 'json',
					timeout: 10000 * 60,
					header: {
						"sysToken": uni.getStorageSync("PMStoken"),
					},
					data: {
						
					},
					success: (res) => {
						uni.hideLoading();
						console.log('获取项目列表数据:' , res);
						//console.log('URL:' + uni.getStorageSync('url') + url);
						var data = res.data;
						if (data.code == "200") {
							
							// if (0 == data.prjInfo.length) {
							// 	this.showLoadMore = true; 
								
							// 	uni.showModal({
    confirmColor: '#eb4b4b',
							// 		title: '温馨提示',
							// 		content: "没有更多数据!",
							// 		showCancel:false,
							// 	})
							// }
							//console.log('子数据:' + JSON.stringify(data.prjInfo));
							// this.list = data.materialLists
							this.materialCard= data.data;
							
							this.materialCloneLists = data.data;
							//this.list=data.data.categoryLevelInfoList;
							//this.show=true
							this.list=[];
							if(data.data.categoryLevelInfoList.length!=0){
								this.placeholder1=this.materialCard.categoryLevelInfoList[0].cateTypeLevel;
								
							}
							this.dataFilterrty(data.data.categoryLevelInfoList,that.materialType)
						}else{
							uni.showModal({
    confirmColor: '#eb4b4b',
								title: '温馨提示',
								content: JSON.stringify(data),
								showCancel:false,
							})
						}
							
						uni.hideLoading();
						uni.stopPullDownRefresh();
							
					},
					fail: (data, code) => {
						uni.hideLoading();
						uni.stopPullDownRefresh();
						console.log('fail' + JSON.stringify(data));
					}
				});
			},
			dataFilterrty(item){
				
				if(item.length!=0){
					
					if(item[0].cateTypeLevel=="4"){
						
						if(item[0].children.length==0){
							this.placeholder1=false;
							item.map(i=>{
								i.children=null;
							})
							
							
							return;
						}
					}
					this.list=item
				}else{
					
					this.list=[{
						cateTypeCode: "",
						cateTypeLevel: "4",
						cateTypeName: "",
					}];
				}
				
				
				
				
			},
			// 贴签赋码接口
			codeLabeling(){
          //如果输入了绑定数量，则需要判断
          if(this.isElectrical && Number(this.detailNum) <= 0){
              uni.showModal({
                  title: '温馨提示',
                  content: "数量(米)输入值不能小于0",
                  showCancel: false,
                  confirmColor: '#eb4b4b',
              })
              return;
          }
				let parems
	            if(this.Sinformation){
					parems= {
						prjId:this.prjId ,
						serviceCode:this.serviceCode ,
						categoryCode:this.materialCode ,
						labelId:this.labelId ,
						isFromPhoto:1,	
						labelLocation:this.Sticker,
						labelPhotoId:this.tupianLister[0].fileUrl,
              isElectrical:this.isElectrical?1:0,
              detailNum:this.isElectrical?this.detailNum: 1   //不显示输入的话，默认传1
					}
				}else{
					parems= {
						prjId:this.prjId ,
						serviceCode:this.serviceCode ,
						categoryCode:this.materialCode ,
						labelId:this.labelId ,
						isFromPhoto:1,	
						labelLocation:"",
						labelPhotoId:"",
              isElectrical:this.isElectrical?1:0,
              detailNum:this.isElectrical?this.detailNum: 1  //不显示输入的话，默认传1
					}
				}
				
				
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				uni.request({
					//url: uni.getStorageSync('url') + "/pms/app/complete/serviceAssignCode?prjId=" + this.prjId +"&serviceCode="+ this.serviceCode +"&categoryCode=" + this.materialCode + "&labelId="+ this.labelId + "&isFromPhoto=1",
					// url: uni.getStorageSync("PMS20url") + "/api/app/serverLable/serviceAssignCode?prjId=" + this.prjId +"&serviceCode="+ this.serviceCode +"&categoryCode=" + this.materialCode + "&labelId="+ this.labelId + "&isFromPhoto=1",
					url: uni.getStorageSync("PMS20url") + "/api/app/serverLable/serviceAssignCode",
					method: 'POST',
					dataType: 'json',
					timeout: 10000 * 60,
					header: {
						"sysToken": uni.getStorageSync("PMStoken"),
					},
					data:parems,
					success: (res) => {
						uni.hideLoading();
						//console.log('列表数据:' + JSON.stringify(res));
						var data = res.data;
						// var result = JSON.stringify(data)
						// console.log('接口数据:' + result);
						if (data.code == "200") {
							uni.showModal({
    confirmColor: '#eb4b4b',
							  title: "温馨提示",
							  content: "赋码贴签成功",
							  showCancel: false,
							  success: () => {
								  this.currenName = "1" //给currenName赋值
								      // --------主要是以下代码---------
								      let pages = getCurrentPages();
								      let prevPage = pages[pages.length - 2];
								      prevPage.$vm.schoolNameert = this.currenName;
								      uni.navigateBack({
								      	delta: 1
								      })
							   },
							  })
							
							
							// uni.showToast({ // 提示框
							// 	title: '赋码贴签成功',
							// 	duration: 1000
							// });
							// uni.hideToast();
				            
								
								
						
						} else {
							uni.showModal({
    confirmColor: '#eb4b4b',
								title: '温馨提示',
								content: data.message,
								showCancel: false,
							})
						}
							
						uni.hideLoading();
						uni.stopPullDownRefresh();
							
					},
					fail: (data, code) => {
						uni.hideLoading();
						uni.stopPullDownRefresh();
						console.log('fail' + JSON.stringify(data));
						uni.showModal({
    confirmColor: '#eb4b4b',
							title: '温馨提示',
							content: '接口请求错误',
							showCancel: false,
						})
					}
				});
			},
			onOk(num){
				
				if(num == 1){
					if(this.Sinformation){
						if(this.Sticker==""){
							uni.showModal({
    confirmColor: '#eb4b4b',
								title: '温馨提示',
								content: "物料编码已赋码成功，请填写贴签位置",
								showCancel: false,
							})
							return
						}
						if(this.tupianLister.length==0){
							uni.showModal({
    confirmColor: '#eb4b4b',
								title: '温馨提示',
								content: "物料编码已赋码成功，请上传贴签照片",
								showCancel: false,
							})
							return
						}
						
					}
					
					
					if(this.materialCode == ''){
						uni.showModal({
    confirmColor: '#eb4b4b',
							title: '温馨提示',
							content: '请先选择物料名称和物料编码',
							showCancel: false,
						})
					}else{
						this.codeLabeling() //请求接口
					}
					
				}else if(num == 2){
					uni.navigateBack({
						delta: 1
					});
				} else{
            console.log(11111)
        }
			}
		}
	}
</script>

<style>
	@import '@/common/common-ui.css';
</style>
<style scoped lang="scss">
	.off{
			position: absolute;
			font-size: 20px;
			font-weight: 900;
			right: 20px;
			top: 10px;
		}
	.h1{
			  display: flex;
			  justify-content: space-around;
			span{
				margin-top: 30px;
				font-size: 20px;
				font-weight: bold;
			}
		  }
		  .top{
			  display: flex;
			  justify-content: space-around;
			  .t-c1,.t-c2{
			   border: 1px solid black;
			   margin-top: 20px;
			   background: #fff;
			   //color: #cccc;
			   // width: 200px;
			   height: 30px;
			   // margin-right: 90px;
			   font-size: 24rpx;
			   padding-left: 10px;
			  }
		  }
	.contentTitle{
		height: 80rpx;
		display: flex;
		align-items: center;
		padding-left: 25rpx;
		border: 1px solid #E4E4E4;
	}
	.item{
		border: 1px solid #E4E4E4;
		margin-top: 5rpx;
		min-height: 100rpx;
		display: flex;
		align-items: center;
		padding-left: 30rpx;
		.itemLeft{
			display: inline-block;
			width: 30%;
			.xing{
				color: red;
			}
		}
		.itemRight{
			// color: #9999B3;
			font-size: 28rpx;
			width: 70%;
		}
	}
	.buttonBox{
		position: fixed;
		bottom: 0;
		width: 100vw;
		display: flex;
		background-color: #FFFFFF;
	}
	.cardStyle{
		width: 100vw;
		height: auto;
		display: flex;
		justify-content: center;
		position: fixed;
		z-index: 999;
		top: 50px;
		right: 0;
		color: #6E6E6E;
		border-radius: 0 0 10px 10px;
		background: #fff;
		padding: 5px 0;
	}
	
	
	.photo-item {
		width: 24%;
		display: inline-block;
	    padding-top: 14rpx;
		//height: 200rpx;
	
		/* display: flex;
		flex-direction: column; */
		position: relative;
	}
	.photo-image {
		width: 140rpx;
		height: 140rpx;
		margin:10 20px;
	}
	.photo-delete-btn {
		width: 20px;
		height: 20px;
		position: absolute;
		top: 0rpx;
		right: 34rpx;
	}
</style>
